<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
		<title>
		</title>
		<link rel="stylesheet" href="./Public/Admin/Bootstrap/Css/bootstrap.min.css" />
		<link rel="stylesheet" href="./Public/Admin/Css/common.css" />
		<script type="text/javascript" src="./Public/jquery-1.8.2.min.js"></script>
		<script type="text/javascript" src="./Public/Admin/uploadify/jquery.uploadify.min.js"></script>
		<link rel="stylesheet" type="text/css" href="./Public/Admin/uploadify/uploadify.css">
		<!--载入百度编辑器-->
		<script type="text/javascript" charset="utf-8" src="Public/Admin/ueditor1_4_3/ueditor.config.js"></script>
		<script type="text/javascript" charset="utf-8" src="Public/Admin/ueditor1_4_3/ueditor.all.min.js"></script>
		<script type="text/javascript" charset="utf-8" src="Public/Admin/ueditor1_4_3/lang/zh-cn/zh-cn.js"></script>
		<!--
		载入js验证
		<link rel="stylesheet" href="./Public/Admin/validate/mzyValidate.css">
		<script type="text/javascript" src="./Public/Admin/validate/mzyValidate.js"></script>
		<script type="text/javascript" src="./Public/Admin/validate/jquery-1.11.3.min.js"></script>
		-->
		<style type="text/css">/*去掉uploadify上传按钮的边框*/

.uploadify-button {
	background-color: transparent;
	border: none;
	padding: 0;
}

.uploadify:hover .uploadify-button {
	background-color: transparent;
}

.hide {
	display: none;
}

body {
	margin-bottom: 100px;
}

#uploadLists li{
	width: 120px;
	height: 70px;
	/*margin-right: 10px;*/
	float: left;
}
#uploadLists li .dian{
	display: block;
	float: left;
	width: 20px;
	height: 20px;
}

</style>
		<script type="text/javascript">$(function() {
	//		抓取分类[name='cate_cid']给他一个 改变事件
	//			给add-spec也就是增加规格按钮一个点击事件
	$('.add-spec').live('click', function() {
			//				找到父级的tr  也就是按钮的父级tr
			var parentsTr = $(this).parents('tr');
			//				 复制父级的tr
			var cloneTr = parentsTr.clone();
			//				  找到辅助出列的 class里面有add-spec的按钮    然后把它里面的add-spec btn-success（颜色）删除       再把这个颜色添加进去remove-spec btn-danger（颜色）      再把里面的字改成删除规格
			cloneTr.find('.add-spec').removeClass('add-spec btn-success').addClass('remove-spec btn-danger').html('删除规格');
			//				最后把克隆出来的tr插到父级的后面
			parentsTr.after(cloneTr);
		})
		//			给他add-spec个点击事件     因为克隆出来的tr 颜色都变了  所有要抓取他remove-spec
	$('.remove-spec').live('click', function() {
			//				一点击 就抓取当前的 tr  然后就删除
			$(this).parents('tr').remove();
		})
		//			给add-spec也就是增加规格按钮一个点击事件
	$('.add-specc').live('click', function() {
			//				找到父级的tr  也就是按钮的父级tr
			var parentsTr = $(this).parents('tr');
			//				 复制父级的tr
			var cloneTr = parentsTr.clone();
			//				  找到辅助出列的 class里面有add-spec的按钮    然后把它里面的add-spec btn-success（颜色）删除       再把这个颜色添加进去remove-spec btn-danger（颜色）      再把里面的字改成删除规格
			cloneTr.find('.add-specc').removeClass('add-spec btn-success').addClass('remove-spec btn-danger').html('删除属性');
			//				最后把克隆出来的tr插到父级的后面
			parentsTr.after(cloneTr);
		})
		//			给他add-spec个点击事件     因为克隆出来的tr 颜色都变了  所有要抓取他remove-spec
	$('.remove-spec').live('click', function() {
		//				一点击 就抓取当前的 tr  然后就删除
		$(this).parents('tr').remove();
	})
})</script>
	</head>
	<body>
		<!--上传列表图-->
		<!--列表图-->
		<!-- html页面 -->
		<div lab="uploadFile">
			<!--<input id="file" type="file" multiple="true">
			<span>类型: *.jpg,*.png 大小: 2000KB 数量: 1</span>-->
			<script type="text/javascript">$(function() {
			$('#file').uploadify({
						'formData': { //POST数据
							'<?php echo session_name(); ?>' : '<?php echo session_id(); ?>',
},
'fileTypeDesc': '上传文件', //上传描述
'fileTypeExts': '*.jpg;*.png',
'swf': '<?php echo __PUBLIC__?>/Admin/uploadify/uploadify.swf',
'uploader': '<?php echo U('Image')?>',
	'buttonText': '选择文件',
	'fileSizeLimit': '2000KB',
	'uploadLimit': 1, //上传文件数
	'width': 80,
	'height': 30,
	'successTimeout': 10, //等待服务器响应时间
	'removeTimeout': 0.2, //成功显示时间
	'onUploadSuccess': function(file, data, response) {
		//转为json
		data = $.parseJSON(data);
		//获得图片地址
		var imageUrl = data.url;
		var li = "<li><img style='width:70px;' src='" + imageUrl + "'/><input type='hidden' name='glist' value='" + data.path + "'/></li>";
		$("#uploadList ul").prepend(li);
	}
});
});</script>
		</div>
		<!--上传商品图册-->
		<!-- html页面 -->
		<div lab="uploadFile">
			<script type="text/javascript">$(function() {
			$('#files').uploadify({
						'formData': { //POST数据
							'<?php echo session_name(); ?>' : '<?php echo session_id(); ?>',
},
'fileTypeDesc': '上传文件', //上传描述
'fileTypeExts': '*.jpg;*.png',
'swf': '<?php echo __PUBLIC__?>/Admin/uploadify/uploadify.swf',
'uploader': '<?php echo U('Images')?>',
	'buttonText': '选择文件',
	'fileSizeLimit':'2000KB',
	'uploadLimit': 10, //上传文件数
	'width': 80,
	'height': 30,
	'successTimeout': 10, //等待服务器响应时间
	'removeTimeout': 0.2, //成功显示时间
	'onUploadSuccess': function(file, data, response) {
		//转为json
		data = $.parseJSON(data);
		//获得图片地址
		var imageUrl = data.url;
		var li = "<li><img style='width:70px;' src='" + imageUrl + "'/><input type='hidden' name='satlas[]' value='" + data.path + "'/></li>";
		$("#uploadLists ul").prepend(li);
	}
});
});</script>
		</div>
		<div class="container-fluid">
			<div class="row-fluid">
				<div class="span12">
					<form action="" method='post'>
						<fieldset>
							<legend>
								添加商品
							</legend>
							<table class='table table-bordered table-hover'>
								<thead>
									<tr>
										<th colspan="2" class="btn btn-primary">
											基本信息
										</th>
									</tr>
								</thead>
								<tbody>
									<tr class="info">
										<td>
											所属分类
										</td>
										<td>
											<select name="cate_cid">
												<option value="0">
													-请选择-
												</option>
												<?php foreach ($cateModel as $v){?>
												<option value="<?php echo $v['cid']?>" tid='{{$v['type_taid']' <?php if($v['cid'] == $goodsModel['cate_cid']){?>
                selected
               <?php }?>>
													<?php echo $v['_name']?>
												</option>
												<?php }?>
											</select>
										</td>
									</tr>
									<tr class="info">
										<td>
											所属品牌
										</td>
										<td>
											<select name="brand_bid">
												<option value="0">
													-请选择-
												</option>
												<?php foreach ($brandModel as $v){?>
												<option value="<?php echo $v['bid']?>" <?php if($v['bid'] == $goodsModel['brand_bid']){?>
                selected
               <?php }?>>
													<?php echo $v['bname']?>
												</option>
												<?php }?>
											</select>
										</td>
									</tr>
									<tr class="info">
										<td>
											商品名称
										</td>
										<td>
											<input type="text" name='gname' value="<?php echo $goodsModel['gname']?>"/>
										</td>
									</tr>
									<tr class="info">
										<td>
											单位
										</td>
										<td>
											<input type="text" name='gunit' value='<?php echo $goodsModel['gunit']?>'/>
										</td>
									</tr>
									<tr class="info">
										<td>
											市价场
										</td>
										<td>
											<input type="text" name='gmar' value="<?php echo $goodsModel['gmar']?>"/>
										</td>
									</tr>
									<tr class="info">
										<td>
											商城价
										</td>
										<td>
											<input type="text" name='gmall' value="<?php echo $goodsModel['gmall']?>"/>
										</td>
									</tr>
									<tr class="info">
										<td>
											点击次数
										</td>
										<td>
											<input type="text" name='gclick' value="<?php echo $goodsModel['gclick']?>"/>
										</td>
									</tr>
								</tbody>
							</table>
							<p class="btn btn-primary">
								商品属性
							</p>
							<?php foreach ($dityAttr as $v){?>
							<table class="table table-bordered table-hover" id='attr' class="info">
								<?php if($v['class']==0){?>
                
								<tr class="info">
									<td>
										<?php echo $v['thname']?>
									</td>
									<td>
										<select name="attr[<?php echo $v['thid']?>]">
											<option value="0">
												-请选择-
											</option>
											<?php foreach ($v['thattr'] as $vv){?>
											<option value="<?php echo $vv?>" <?php if($v['dattr']== $vv){?>
                selected
               <?php }?>>
												<?php echo $vv?>
											</option>
											<?php }?>
										</select>
									</td>
								</tr>
								
               <?php }?>
							</table>
							<?php }?>
							<p class="btn btn-primary">
								商品规格
							</p>
							<table class="table table-bordered table-hover" id='attr' class="info">
							<?php foreach ($dityAttr as $v){?>
								<?php if($v['class']==1){?>
                
								<tr class="info">
									<td>
										<?php echo $v['thname']?>
									</td>
									<td>
										<select name="spec[<?php echo $v['thid']?>][thattr][]">
											<option value="0">
												-请选择-
											</option>
											<?php foreach ($v['thattr'] as $vv){?>
											<option value="<?php echo $vv?>" <?php if($v['dattr']== $vv){?>
                selected=""
               <?php }?>>
												<?php echo $vv?>
											</option>
											<?php }?>
										</select>
									</td>
									<td>
										附加价格:
									</td>
									<td>
										<input type="text" name="spec[<?php echo $v['thid']?>][dadd][]" id="" value="<?php echo $v['dadd']?>"/>
									</td>
									<td>
								<!--判断在不在这个数组里  in_array-->
										<?php if(in_array($v['did'],$id)){?>
                
											<span class="btn btn-success add-spec">增加规格</span>
										<?php }else{?>
												<span class="btn remove-spec btn-danger">删除规格</span>
										
               <?php }?>
									</td>
								</tr>
								
               <?php }?>
							<?php }?>
							</table>

							<table class='table table-bordered'>
								<tr>
									<th colspan="3" class="btn btn-primary">
										列表图
									</th>
								</tr>
								<tr class="info">
									<td>
										上传图片
									</td>
								<?php if($goodsModel['glist']){?>
                
									<td class="tts" style="display: none;">
										<input id="file" type="file" multiple="true">
										<div id="uploadList">
											<ul>
											</ul>
										</div>
									</td>
									<td class="xx">
										<!--<input class="tts" style="display: none;" id="file" type="file" multiple="true">-->
										<div id="uploadList">
											<ul>
												<li >
													<img style="width: 90px;" src="<?php echo $goodsModel['glist']?>"/>
													<a href="javascript:;" class="dian">
														X
													</a>
													<input type="hidden" name="glist" value="<?php echo $goodsModel['glist']?>"/>
												</li>
											</ul>
										</div>
									</td>
									<td id='pic-list'>
									</td>
								<?php }else{?>
									<td >
										<input id="file" type="file" multiple="true">
										<div id="uploadList">
											<ul>
											</ul>
										</div>
									</td>
								
               <?php }?>
								</tr>
							</table>
							<script type="text/javascript">$(function() {
								$(".dian").click(function() {
									$(".xx").remove();
									$(".tts").show();
								});
								$(".popup").click(function() {
									$(this).parent().remove();
								})
							})</script>

							
							<table class='table table-bordered'>
								<tr>
									<th colspan="3" class="btn btn-primary">
										商品图册
									</th>
								</tr>
								<tr class="info">
									<td>
										上传图片
									</td>
								<?php if($goodsModel['satlas']){?>
                
									<td>
										<input id="files" type="file" multiple="true">
										<span>共可以上传10张图片</span>
										<td>
											<div id="uploadLists">
												<ul>
													<?php foreach ($goodsModel['satlas'] as $v){?>
														<li>
															<img style="width: 80px;" src="<?php echo $v?>"/>
															<a href="javascript:;" class="popup">
																X
															</a>
															<input type="hidden" name="satlas[]" value="<?php echo $v?>"/>
														</li>
													<?php }?>
												</ul>
											</div>
										</td>
									</td>
								<?php }else{?>
									<td>
										<input id="files" type="file" multiple="true">
										<td>
											<div id="uploadLists">
												<ul>
													
												</ul>
											</div>
										</td>
									</td>
								
               <?php }?>
									<td id='photo-list'>
									</td>
								</tr>
							</table>
							
							
							
							
							<table class='table'>
								<tr class="next_show">
									<th class="btn btn-primary">
										商品详细
									</th>
									<!--调用百度编辑器-->
									<script id="editor" type="text/plain" style="width:100%;height:500px;" name="sdeta">
										<?php echo $goodsModel['sdeta']?>
									</script>
									<script>var ue = UE.getEditor('editor');</script>
								</tr>
							</table>
							<table class='table'>
								<tr class="next_show">
									<th class="btn btn-primary">
										售后服务
									</th>
									<!--调用百度编辑器-->
									<script id="editors" type="text/plain" style="width:100%;height:350px;" name="safter">
										<?php echo $goodsModel['safter']?>
									</script>
									<script>var ue = UE.getEditor('editors');</script>
								</tr>
							</table>
							<input type="hidden" name='gid' value="<?php echo $goodsModel['gid']?>"/>
							<input type="submit" value="确认添加" class="btn btn-primary btn-block btn-large" />
						</fieldset>
					</form>
				</div>
			</div>
		</div>

	</body>
</html>